﻿using Microsoft.AspNetCore.Mvc;
using SC.UserCenter.Infra;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Acme.BookStore.BasicInformations
{
    /// <summary>
    /// 基本信息接口实现
    /// </summary>
    [ApiExplorerSettings(GroupName = "v2")]
    public class BasicInformationServices : ApplicationService, IBasicInformationServices
    {
        /// <summary>
        /// 注入
        /// </summary>
        private readonly IRepository<BasicInformation> repository;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="repository"></param>
        public BasicInformationServices(IRepository<BasicInformation> repository)
        {
            this.repository = repository;
        }

        /// <summary>
        ///添加基本信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost("PostBasicInformation")]
        public async Task<ApiResult> PostBasicInformation(BasicInformationDTO dto)
        {
            var list = ObjectMapper.Map<BasicInformationDTO, BasicInformation>(dto);
            await repository.InsertAsync(list);
            return ApiResult.Ok(data: list);
        }
    }
}
